import { defineStore } from 'pinia'

const appStore = defineStore('app', {
  state: () => {
    return {
      token: localStorage.getItem('token') || '',
      networkState: true,
      showMenu: false,
    }
  },
  actions: {
    setToken(token: string = '') { //语言切换
      this.token = token
      localStorage.setItem('token', token)
    },
    setNetworkState(status: boolean = true) { //语言切换
      this.networkState = status
    },
    setMenuState(status: boolean = false) {
      this.showMenu = status
    },
  }
})

export default appStore
